<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单列表</title>
    <script src="js/axios.min.js"></script>
    <script src="js/vue.min.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="ele-2.15.7/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="ele-2.15.7/index.js"></script>
</head>
<body>
<div id="app">
    <div class="main-container">

        <div class="el-card">
            <div class="el-card__body">
                <div>
                    <i class="el-icon-search"></i>
                    <span>筛选搜索</span>

                    <button type="button" class="el-button el-button--primary el-button--small" style="float: right" @click="resetInput">
                        <span>重置</span>
                    </button>
                    <button type="button" class="el-button el-button--default el-button--small" style="float: right;margin-right: 15px"  @click="query(1)">
                        <span>查询搜索</span>
                    </button>
                </div>
            </div>

            <div style="margin-top: 15px;">
                <el-form :inline="true"  class="demo-form-inline" style="margin-left: 20px">
                    <el-form-item label="输入搜索:">
                        <el-input v-model="orderid" placeholder="服务单号"></el-input>
                    </el-form-item>
                    <el-form-item label="处理状态:">
                        <el-select v-model="status" placeholder="待处理">
                            <el-option
                                    v-for="item in statusOption"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="申请时间:">
                        <el-col :span="35">
                            <el-date-picker type="returndate" placeholder="选择日期" v-model="returntime" style="width: 100%;"></el-date-picker>
                        </el-col>
                    </el-form-item>
                    <el-form-item label="操作人员:">
                        <el-input v-model="aid" placeholder="全部"></el-input>
                    </el-form-item>
                    <el-form-item label="处理时间:">
                        <el-col :span="35">
                            <el-date-picker type="handledate" placeholder="选择日期" v-model="handletime" style="width: 100%;"></el-date-picker>
                        </el-col>
                    </el-form-item>
                </el-form>
            </div>

        </div>

        <el-card class="box-card operate-container " shadow="never">
            <i class="el-icon-tickets"></i>
            <span>数据列表</span>
        </el-card>

        <div style="height: 20px"></div>

        <div class="table-container">
            <el-table
                    :header-cell-style="{'text-align':'center'}"
                    :cell-style="{'text-align':'center'}"
                    border  :data="tableData.data" style="width: 100%"
                      >
                <el-table-column fixed prop="orderid" label="服务单号" width="180"></el-table-column>
                <el-table-column prop="returntime" label="申请时间" width="269">
                    <template slot-scope="scope">
                    <span v-if="scope.row.returntime==null">暂无</span>
                    <span v-if="scope.row.returntime!=null">{{ scope.row.returntime | formatTimer }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="uid" label="用户账号" width="159"></el-table-column>
                <el-table-column prop="currentprice" label="退款金额" width="180"></el-table-column>
                <el-table-column prop="status" label="申请状态" width="180"></el-table-column>
                <el-table-column prop="handletime" label="处理时间" width="283">
                    <template slot-scope="scope">
                        <span v-if="scope.row.handletime==null">暂无</span>
                        <span v-if="scope.row.handletime!=null">{{ scope.row.handletime | formatTimer }}</span>
                    </template>
                </el-table-column>
                <el-table-column  label="操作" width="219">
                    <template slot-scope="scope">
                        <el-button size="small">查看详情</el-button>
                    </template>
                </el-table-column>

            </el-table>
            <el-footer style="text-align: right">
                <el-pagination :page-size="pageSize" @current-change="query" @size-change="sizeChange"
                               background :page-sizes="[10,15,20]"
                               layout="total,sizes,prev, pager,next,jumper"
                               :total="tableData.total"
                               :current-page.sync="tableData.page">
                </el-pagination>
            </el-footer>
        </div>
    </div>
</div>

<script>
    var v = new Vue({
        el : "#app",
        data : {
            // tableData: [],
            orderid : "",
            aid : "",
            pageSize: 10,

            currentprice : "",
            handletime : new Date(),
            returntime : new Date(),
            // returnhandletime : "",
            // returntime : "",
            status: "",
            statusOption : [{
                label: "待处理",
                value: "0"
            },{
                label: "退货中",
                value: "10"
            },{
                label: "已完成",
                value: "20"
            },{
                label: "已拒绝",
                value: "30"
            }
            ],
            //表格数据
            tableData: {page:1}
        },
        created() {
            this.query(1);

        },
        methods : {
            query(page) {
                axios.get("ReturnRequestServlet.s",{
                    params: {
                        orderid : this.orderid,
                        aid : this.aid,
                        returntime : this.returntime = new Date()  ? "" : this.returntime.toLocaleDateString().replace(/\//g, '-'),
                        handletime : this.handletime = new Date() ? "" :  this.handletime.toLocaleDateString().replace(/\//g, '-'),
                        status : this.status,
                        currentPage : page, //当前页数
                        pageSize: this.pageSize //每页显示条目个数
                    }
                }).then(res=>{
                    this.tableData = res.data;
                    this.tableData.page = page;

                })
            },

            sizeChange(page){
                this.pageSize =page;
                this.query(1);
            },
            resetInput(){
                this.orderid = "";
                this.status = "";
                this.returntime = "";
                this.handletime = "";
                this.aid = "";
            }
        },

        filters: {
            formatTimer: function(value) {
                    let date = new Date(value);
                    let y = date.getFullYear();
                    let MM = date.getMonth() + 1;
                    MM = MM < 10 ? "0" + MM : MM;
                    let d = date.getDate();
                    d = d < 10 ? "0" + d : d;
                    let h = date.getHours();
                h = h < 10 ? "0" + h : h;
                let m = date.getMinutes();
                m = m < 10 ? "0" + m : m;
                let s = date.getSeconds();
                s = s < 10 ? "0" + s : s;
                return y + "-" + MM + "-" + d + " " + h + ":" + m;
            }
        },
    })
</script>

</body>
</html>
